% Export script in MATLAB for conversion of data to flat files with documentation:


% Units are explained below for each file. If there exists a "vx_frame.txt"
% for the observation technique, then the rotation velocity measured is on
% top of this vx_frame velocity. If no such vx_frame exists for the
% dataset, then the velocity given is in the sidereal frame.

% GHS1
savestructfield('data_export/GHS1_lat.txt',antia,'lat');            % Latitude in degrees
savestructfield('data_export/GHS1_depth.txt',antia,'depth');        % depth (Mm) below the photosphere
savestructfield('data_export/GHS1_CR.txt',antia,'cr');              % Carrington Rotation (CR#)
savestructfield('data_export/GHS1_vx.txt',antia,'vx');              % nHz (depth,lat,CR) (17,90,259) flattened into (1530,259)
savestructfield('data_export/GHS1_vx_error.txt',antia,'vx_error');  % nHz (depth,lat,CR) (17,90,259) flattened into (1530,259)
savestructfield('data_export/GHS1_vx_frame.txt',antia,'vx_frame');  % nHz (lat)
savestructfield('data_export/GHS1_acc.txt',antia,'acc');            % 10-8 m/s/s (lat,CR) only near surface (top layer in depth)
savestructfield('data_export/GHS1_meanvx_overlap.txt',antia,'meanvx_overlap');            % nHz (depth,lat)
savestructfield('data_export/GHS1_error_meanvx_overlap.txt',antia,'error_meanvx_overlap');            % nHz (depth,lat)

% GHS2
savestructfield('data_export/GHS2_lat.txt',jsoc_hmi,'lat');          % Latitude in degrees
savestructfield('data_export/GHS2_depth.txt',jsoc_hmi,'depth');      % depth (Mm) below the photosphere
savestructfield('data_export/GHS2_CR.txt',jsoc_hmi,'cr');            % CR#
savestructfield('data_export/GHS2_vx.txt',jsoc_hmi,'vx');            % nHz (depth,lat,CR)
savestructfield('data_export/GHS2_vx_error.txt',jsoc_hmi,'vx_error');% nHz (depth,lat,CR)
savestructfield('data_export/GHS2_vx_frame.txt',jsoc_hmi,'vx_frame');% nHz (lat)
savestructfield('data_export/GHS2_acc.txt',jsoc_hmi,'acc');          % 10-8 m/s/s (lat,CR) only near surface
savestructfield('data_export/GHS2_meanvx_overlap.txt',jsoc_hmi,'meanvx_overlap');            % nHz (depth,lat)
savestructfield('data_export/GHS2_error_meanvx_overlap.txt',jsoc_hmi,'error_meanvx_overlap');    % nHz (depth,lat)  

% GHS3
savestructfield('data_export/GHS3_lat.txt',antia_mdihmi,'lat');            % degrees
savestructfield('data_export/GHS3_depth.txt',antia_mdihmi,'depth');        % depth (Mm) below the photosphere
savestructfield('data_export/GHS3_CR.txt',antia_mdihmi,'cr');              % CR#
savestructfield('data_export/GHS3_vx.txt',antia_mdihmi,'vx');              % nHz (depth,lat,CR)
savestructfield('data_export/GHS3_vx_error.txt',antia_mdihmi,'vx_error');  % nHz (depth,lat,CR)
savestructfield('data_export/GHS3_vx_frame.txt',antia_mdihmi,'vx_frame');  % nHz (lat)
savestructfield('data_export/GHS3_acc.txt',antia_mdihmi,'acc');            % 10-8 m/s/s (lat,CR) only near surface
savestructfield('data_export/GHS3_meanvx_overlap.txt',antia_mdihmi,'meanvx_overlap');            % nHz (depth,lat)
savestructfield('data_export/GHS3_error_meanvx_overlap.txt',antia_mdihmi,'error_meanvx_overlap');            % nHz (depth,lat)


% RD1
savestructfield('data_export/RD1_lat.txt',tripathy,'lat');          % Latitude in degrees
savestructfield('data_export/RD1_depth.txt',tripathy,'depth');      % Mm
savestructfield('data_export/RD1_depth_error.txt',tripathy,'depth_error');   % Mm
savestructfield('data_export/RD1_meanvx.txt',tripathy,'meanvx_overlap'); % nHz
savestructfield('data_export/RD1_vx_frame.txt',tripathy,'vx_frame');     % nHz
savestructfield('data_export/RD1_vx_error.txt',tripathy,'error_meanvx_overlap'); % nHz

% RD2
savestructfield('data_export/RD2_lat.txt',komm,'lat');              % Latitude in degrees
savestructfield('data_export/RD2_CR.txt',komm,'cr');                % CR#
savestructfield('data_export/RD2_meanvx_overlap.txt',komm,'meanvx_overlap');       % nHz (lat)
savestructfield('data_export/RD2_vx.txt',komm,'vx');                % nHz  (lat,CR)
savestructfield('data_export/RD2_error_meanvx_overlap.txt',komm,'error_meanvx_overlap');  % nHz (lat)
savestructfield('data_export/RD2_error_vx.txt',komm,'vx_error');    % nHz (lat,CR)
savestructfield('data_export/RD2_vx_frame.txt',komm,'vx_frame');    % nHz (lat)
savestructfield('data_export/RD2_acc.txt',komm,'acc');              % 10-8 m/s/s (lat,CR(last 257 CR))

% TD (Available from SDR as well? - the same dataset?)
savestructfield('data_export/TD_lat.txt',zhao,'lat');               % Latitude in degrees
savestructfield('data_export/TD_CR.txt',zhao,'cr');                 % CR#
savestructfield('data_export/TD_vx.txt',zhao,'vx');                 % nHz (lat,CR)
savestructfield('data_export/TD_vx_error.txt',zhao,'vx_error');     % nHz (lat,CR)
savestructfield('data_export/TD_vx_frame.txt',zhao,'vx_frame');     % nHz (lat)
savestructfield('data_export/TD_meanvx_overlap.txt',zhao,'meanvx_overlap');    % nHz (lat)
savestructfield('data_export/TD_error_meanvx_overlap.txt',zhao,'error_meanvx_overlap');    % nHz (lat)
savestructfield('data_export/TD_acc.txt',zhao,'acc');               % 10-8 m/s/s (lat,CR)

% DD
savestructfield('data_export/DD_A_lat.txt',ulrich,'lat');            % Latitude in degrees
savestructfield('data_export/DD_A_meanvx_overlap_sidereal.txt',ulrich,'vx_overlap');  % nHz (lat) CR 2096-2105
savestructfield('data_export/DD_B_lat.txt',ulrich.Fe1,'lat');        % degrees
savestructfield('data_export/DD_B_time.txt',ulrich.Fe1,'time');      % years
savestructfield('data_export/DD_B_vx.txt',ulrich.Fe1,'rot');         % nHz sidereal rotation (lat, time(CR bins))
savestructfield('data_export/DD_B_acc.txt',ulrich.Fe1,'acc');        % 10-8 m/s/s (lat,CR)

% GT
savestructfield('data_export/GT_lat.txt',thierry,'lat');            % Latitude in degrees
savestructfield('data_export/GT_meanvx.txt',thierry,'meanvx');      % nHz
savestructfield('data_export/GT_vx_frame.txt',thierry,'vx_frame');  % nHz
savestructfield('data_export/GT_vx_error.txt',thierry,'vx_error');  % nHz

% MPT1
savestructfield('data_export/MPT1_lat.txt',upton,'lat');            % Latitude in degrees
savestructfield('data_export/MPT1_CR.txt',upton,'cr');              % CR#
savestructfield('data_export/MPT1_meanvx_overlap.txt',upton,'meanvx_overlap');    % nHz
savestructfield('data_export/MPT1_vx.txt',upton,'vx');              % nHz
savestructfield('data_export/MPT1_acc.txt',upton,'acc');            % 10^-8 m/s/s  (lat,CR)
savestructfield('data_export/MPT1_vx_frame.txt',upton,'vx_frame');  % nHz

% MPT2
savestructfield('data_export/MPT2_lat.txt',mahajan,'lat');            % Latitude in degrees
savestructfield('data_export/MPT2_CR.txt',mahajan,'cr');              % CR#
savestructfield('data_export/MPT2_meanvx_overlap.txt',mahajan,'meanvx_overlap');  % nHz (CR 2096-2105)
savestructfield('data_export/MPT2_vx.txt',mahajan,'vx');              % nHz
savestructfield('data_export/MPT2_acc.txt',mahajan,'acc');            % 10^-8 m/s/s  (lat,CR)
savestructfield('data_export/MPT2_vx_frame.txt',mahajan,'vx_frame');  % nHz